<?php 
class App_User_Pager_AdminRole extends Main_Pager
{
	/**
	 * @var array
	 */
	protected $_fields = array(
		'id'   => array('simpleSearch' => 'true', 'sql' => 'role.id'),
		'code' => array('simpleSearch' => 'true', 'sql' => 'role.code'),
		'name' => array('simpleSearch' => 'true', 'sql' => 'role_i18n.name'),
	);
	
	/**
	 * @return void
	 */
	protected function _init()
	{
		$this->_config['base'] = "
			SELECT 
				role.id
				, role.code
				, role_i18n.name 	
			FROM
				role
			INNER JOIN
				role_i18n 
				ON
					(role.id=role_i18n.role_id AND role_i18n.lang_id={$this->_langId})
			WHERE true		
		";
		
		
				
		$this->_config['count'] = "
			SELECT 
				COUNT(role.id)
			FROM
				role 
			INNER JOIN
				role_i18n 
				ON
					(role.id=role_i18n.role_id AND role_i18n.lang_id={$this->_langId})	
			WHERE true	
		";		

		$this->_service = new App_User_Service_Role();
						
		parent::_init();			
	}
	
	/**
	 * @param int|string $primary
	 * @return bool
	 */
	protected function _deleteItem($primary) 
	{
		return $this->_service->deleteItem($primary);
	}
}


